(function (doc, win) {
  var docEl = doc.documentElement,
    resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
    recalc = function () {
      var clientWidth = docEl.clientWidth
      if (!clientWidth) return
      docEl.style.fontSize = 10 * (clientWidth / 75) + 'px'
    }
  if (!doc.addEventListener) return
  win.addEventListener(resizeEvt, recalc, false)
  doc.addEventListener('DOMContentLoaded', recalc, false);
  //微信授权
var isWX=function(){
	  var ua = window.navigator.userAgent.toLowerCase();
			      //mozilla/5.0 (iphone; cpu iphone os 9_1 like mac os x) applewebkit/601.1.46 (khtml, like gecko)version/9.0 mobile/13b143 safari/601.1
		if (ua.match(/MicroMessenger/i) == 'micromessenger') {
			return true;
		} else {
			return false;
		}
}
function getCookie(cookieName) {
    var strCookie = document.cookie;
    var arrCookie = strCookie.split("; ");
    for(var i = 0; i < arrCookie.length; i++){
        var arr = arrCookie[i].split("=");
        if(cookieName == arr[0]){
            return arr[1];
        }
    }
    return false;
}
if(isWX()){
	if(localStorage.getItem("nt_user")&&localStorage.getItem("nt_user")!=0){
		
	}else{
		if(getCookie('token')&&getCookie('dst_status')){
			console.log(333);
			localStorage.setItem("nt_user",getCookie('token'));
			localStorage.setItem("nt_stute",getCookie('dst_status'));
			location.reload();
		}else{
			console.log(444);
			
//			var returl=location.href;
//			$.ajax({
//				type:"get",
//				url:"http://www.ntyouxuan.com/index.php?app=ajax_third_login&act=wx_code",
//				data:{'type':2,'ret_url':returl},
//				dataType:'json',
//				success:function(res){
//					if(res.done){
////						location.href=res.retval;
//					}
//				}
//			});
		}
		
	}
}
  //时间格式
  Date.prototype.Format = function (fmt) { //author: meizz  
				var o = {  
				    "M+": this.getMonth() + 1, //月份  
				    "d+": this.getDate(), //日  
				    "h+": this.getHours(), //小时  
				    "m+": this.getMinutes(), //分  
				    "s+": this.getSeconds(), //秒  
				    "q+": Math.floor((this.getMonth() + 3) / 3), //季度  
				    "S": this.getMilliseconds() //毫秒  
				};  
				if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));  
				for (var k in o)  
				if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));  
				return fmt;  
	};
			//返回地址链接
  return furl="http://www.ntyouxuan.com/";
  
})(document, window)
